/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.gidoo.websites.example.plugins;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;
import org.gidoo.cms.IEditPlugin;

/**
 *
 * @author thomas
 */
public class TestEditingPlugin implements IEditPlugin
{

  String currentSelectedPage = null;
  MyPanel p;
  
  public void setCurrentSelectedPage(Node currentSelectedPage)
  {
    try
    {
      this.currentSelectedPage = currentSelectedPage == null ? null 
        : currentSelectedPage.getPath();
    }
    catch(RepositoryException ex)
    {
      Logger.getLogger(TestEditingPlugin.class.getName()).log(Level.SEVERE, null, ex);
    }
  }

  public String getPluginName()
  {
    return "Example";
  }

  public Panel getPluginPanel(String id)
  {
    return new MyPanel(id, currentSelectedPage);
  }

  public class MyPanel extends Panel
  {
    public MyPanel(String id, String pathToNode)
    {
      super(id);
      add(new Label("lblPath", new Model(pathToNode != null ? pathToNode : "null")));
    }
  }
  
}
